import { http } from '@/utils/http'
import { baseUrlApi } from './types'
import type { ObjectResult } from './types'
import type { userType } from '@/stores/user'

export interface UserResult extends userType {
  token: string
}
export const authApi = () => {
  return http.request<ObjectResult<UserResult>>('post', baseUrlApi('/auth'))
}

export const codeApi = (code: string) => {
  return http.request<ObjectResult<UserResult>>('post', baseUrlApi('/code'), {
    data: { code }
  })
}

export const bindApi = (data: Object) => {
  return http.request<ObjectResult<UserResult>>('post', baseUrlApi('/bind'), {
    data
  })
}

export const captchaApi = () => {
  return http.request<ObjectResult<string>>('get', baseUrlApi('/captcha'))
}

export const smsApi = (data: Object) => {
  return http.request<ObjectResult<string>>('post', baseUrlApi('/sms'), { data })
}
